home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 247 / 247.d81 / e.fave zps < prev    next >
Text File  |  2022-08-26  |  6KB  |  213 lines

  1. u                            PRINT THIS
  2.  
  3.         FAMOUS ZERO-PAGE BYTES
  4.         ----------------------
  5.  
  6.             by Fender Tucker
  7.  
  8.     The first 256 memory locations
  9. used by your C64 are very important
  10. to BASIC programs but there are only
  11. a couple of dozen of them that you
  12. really need to know about. These are
  13. the locations I use most often.
  14.  
  15.     I'm taking a lot of this
  16. information from my second-most-
  17. important C64 book, "Mapping the C64"
  18. by Sheldon Leemon, Compute!
  19. Publications, Inc. The most
  20. important is, of course, the
  21. "Programmer's Reference Guide" by
  22. Commodore Business Machines, Inc.
  23.  
  24.  
  25.  ZERO PAGE - Locations 0 through 255
  26.  
  27. 0 and 1 - Very important for I/O and
  28.   switching the ROMs in and out.  Bits
  29.   0, 1 and 2 of location 1 are the
  30.   operative switches. Here's what
  31.   these bits do:
  32.  
  33.  Bit
  34.  
  35.   0  On   BASIC ROM at $A000 (40960)
  36.      Off  RAM at $A000
  37.  
  38.   1  On   Kernal ROM at $E000 (57344)
  39.      Off  RAM at $E000
  40.  
  41.   2  On   I/O at $D000 (53248)
  42.      Off  Character ROM at $D000
  43.  
  44. 2 - Unused by BASIC.  This is a
  45.   favorite place to store a value
  46.   between 0 and 255. Be careful
  47.   though, it's used by a lot of ML
  48.   routines.
  49.  
  50. 19 - Default value is 0. If you POKE
  51.   a 64 here, the ? is suppressed from
  52.   an INPUT statement. Be sure to POKE
  53.   a 0 back in after you get your input
  54.   or you'll have cursor problems with
  55.   the BASIC screen editor. Since
  56.   LOADSTAR is not a fan of the INPUT
  57.   statement anyway, my advice is to
  58.   use this for your own programs, if
  59.   you want, but not for programs to be
  60.   used by the general public.
  61.  
  62.  
  63. 43 and 44 - Pointers to the start of
  64.   BASIC text. Default is 01 and 08 or
  65.   2049 decimal. To move the start of
  66.   BASIC text up to $1001 (4097) you
  67.   need to POKE 44,10:POKE 4096,0 in a
  68.   boot program. This allows enough
  69.   room for a font to be LOADed at
  70.   $0800. These locations are also
  71.   temporarily changed when appending
  72.   BASIC programs. If you ever get a
  73.   "syntax error" when entering a
  74.   simple BASIC command like RUN, you
  75.   probably need to POKE2048,0. If
  76.   you've moved BASIC up, then POKE a 0
  77.   into the value returned by
  78.   PEEK(44)*256.
  79.  
  80. 45 and 46 - Start of Variables (SOV)
  81.   or, in another sense, end of
  82.   program. These bytes change as you
  83.   modify your program.  Used in
  84.   appending also.
  85.  
  86. 51 and 52, 55 and 56 - Usually only
  87.   the hi-bytes (52 and 56) need to be
  88.   changed to lower the top of BASIC.
  89.   The default value for 52 and 56 is
  90.   160 which places the top of BASIC
  91.   area at $A000 (40960).
  92.   160x256=40960. To free up room for
  93.   data, ML routines or whatever, poke
  94.   52 and 56 with a lower number.
  95.  
  96. 197 and 203 - In "Mapping the C64"
  97.   there is a table of the values found
  98.   in these locations depending on
  99.   which key has been pressed. They are
  100.   the same for both locations except
  101.   that 197 shows the LAST key pressed,
  102.   while 203 shows the CURRENT key
  103.   pressed. These locations are handy
  104.   for checking for a keypress.
  105.  
  106.   In the immediate mode enter this
  107.   command,
  108.  
  109.     FORI=0TO9000:?PEEK(197);:NEXT
  110.  
  111.   and press RETURN.  A bunch of 64's
  112.   will be printed on the screen.
  113.  
  114.     Then press any key and see what
  115.   number is printed. For instance, if
  116.   you press the SPACE bar the number
  117.   60 will be printed. Therefore
  118.  
  119.   10 IF PEEK (197) = 60 THEN....
  120.  
  121.   is the same as
  122.  
  123.   10 GET A$: IF A$ = " " THEN....
  124.  
  125.   If no key is pressed, both 197 and
  126.   203 will contain a 64.
  127.  
  128.     This checks only for which key is
  129.   pressed. The SHIFT, CONTROL and LOGO
  130.   keys are not part of the keyboard
  131.   matrix so SHIFT-SPACE will give the
  132.   same value as unSHIFTed-SPACE.
  133.  
  134. 198 - Number of characters in the
  135.   keyboard buffer queue. Default is 0.
  136.  
  137.     To make sure that a previous
  138.   keypress is not lurking in the
  139.   buffer it's good programming
  140.   practice to POKE 198,0 before any
  141.   GET statement. Even more useful is
  142.   to POKE some BASIC tokens into the
  143.   keyboard buffer at 631 and then POKE
  144.   the number of tokens into 198. When
  145.   the program ends the commands you
  146.   POKEd will be executed even though
  147.   the program is over and no keys are
  148.   pressed! This is known as the
  149.   dynamic keyboard technique and is
  150.   handy for causing one program to
  151.   LOAD and RUN another. Just about all
  152.   of our boot programs use this
  153.   method. Check 'em out.
  154.  
  155. 199 - A quick way to tell if you are
  156.   in the reversed mode.  0 = no.  1 =
  157.   yes. You can POKE or PEEK this
  158.   location from within your program.
  159.  
  160. 212 - An easy way to get out of the
  161.   quote mode from within a program. 0
  162.   = no. If you want to PRINT a quote
  163.   mark on the screen but don't want
  164.   the user to be in the quote mode,
  165.   just POKE 212,0 afterwards.
  166.  
  167. 214 - The best way (in my opinion) to
  168.   position your cursor in a program is
  169.   to POKE the row you want the cursor
  170.   on (minus 2) into 214.  For
  171.   instance, POKE 214,12:PRINT will
  172.   position the cursor on the 14th row.
  173.   Use TAB or SPC to set the cursor Y
  174.   position.
  175.  
  176. 217 through 242 - Screen line link
  177.   table. These are twenty-five bytes
  178.   (corresponding to the 25 screen
  179.   rows) that need to be manipulated
  180.   whenever you PRINT something in the
  181.   far right column. You'll notice that
  182.   you are having a heck of a time
  183.   getting succeeding text to print on
  184.   the correct line. If you have this
  185.   problem, do this:
  186.  
  187.      200 FOR I = 217 TO 242: POKE I,
  188.       PEEK(I) OR 128:NEXT
  189.  
  190.   and the screen will format
  191.   correctly. Technically, you only
  192.   need to do this for the offending
  193.   line but it's quick enough to fix
  194.   all the links at once in a FOR-NEXT
  195.   loop.
  196.  
  197. 251 through 254 - These are favorite
  198.   free zero-page bytes for ML
  199.   programmers. Some of the addressing
  200.   modes require that addresses be in
  201.   zero page and since addresses are
  202.   two bytes long, having four in a row
  203.   is indeed handy.
  204.  
  205.     By studying Sheldon Leemon's book
  206.   you'll find many more interesting
  207.   locations to play around with.
  208.   These are the ones I have used most
  209.   often in my programs.
  210.  
  211.  FT
  212.  
  213.  
  214.